from queue import Queue
from typing import Any

from CameraSDK_class import CameraSDK
import time
import cv2
import queue

if __name__ == "__main__":
    from MvCameraControl_class import loadCameraDll

    loadCameraDll()
    obj_camera = CameraSDK(0)
    if obj_camera.find_device() == 0:
        exit()
    obj_camera.open_device()

    q_image = queue.Queue()
    q_image.maxsize = 5
    obj_camera.start_grabbing(q_image)

    obj_camera.Set_CamParameter(14, 30000, 1.0)
    obj_camera.Get_CamParameter()

    for i in range(600000):
        image = None
        image = q_image.get()

        # if i == 200:
        #     obj_camera.Set_CamParameter(14, 90000, 1.0)
        #     obj_camera.Get_CamParameter()
        #     obj_camera.Set_CamMode(True)
        #     obj_camera.Set_Trigger_once()

        image = cv2.resize(image, (600, 400), interpolation=cv2.INTER_AREA)
        cv2.rectangle(image, (100, 100), (300, 300), (255, 0, 255), 2)
        cv2.imshow('test', image)
        k = cv2.waitKey(10)

    cv2.destroyWindow('test')
    obj_camera.stop_grabbing()
    obj_camera.close_device()



